<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>编辑分公司信息</title>
    {include file="common/linkcss" /}
</head>


<body>

    <div class="container-fluid">
        <div class="row">

            {include file="common/sidebar" /}

            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">

                <div class="card border-primary  ">
                    <form action="{:url('edit',array('id'=>$company['id']))}" method="POST" enctype="multipart/form-data">
                        <div class="card-header">
                            <h1 class="page-header">
                                编辑分公司信息
                            </h1>
                        </div>
                        <div class="card-body">
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">分公司名称（用于名片选择,不展示在名片）</label>
                                <input class="form-control form-control-lg" name="title" type="text" placeholder="" value="{$company.title}" required autofocus>
                            </div>
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">分公司地址</label>
                                <input class="form-control form-control-lg" id="adrress" name="adrress" type="text" value="{$company.adrress}" placeholder="" required>
                            </div>
                            <div class="row">
                                <div class="col-lg-6 form-group ">
                                    <label class="col-form-label col-form-label-lg" for="storename">
                                        公司坐标经纬度
                                        <button type="button" onclick="getLocation()" class="btn btn-primary btn-sm">上方输入公司地址，点击此处获取</button>
                                    </label>
                                    <input type="text" id="lat" name="lat" class="form-control form-control-lg" value="{$company.lat}" readonly>
                                </div>
                                <div class="col-lg-6 form-group " style="padding-top:3px;">
                                    <label class="col-form-label col-form-label-lg" for="storename">&nbsp;</label>
                                    <input type="text" id="lng" name="lng" value="{$company.lng}" class="form-control form-control-lg" readonly>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">分公司电话</label>
                                <input class="form-control form-control-lg" name="tel" type="text" placeholder="" value="{$company.tel}" required>
                            </div>
                        </div>
                        <div class="card-footer">
                            <button type="submit" class="btn btn-warning btn-lg">确认修改提交</button>
                        </div>
                    </form>
                </div>


            </div>
            <!-- main end -->


        </div>
    </div>
    <!-- container end -->
    <script src="https://map.qq.com/api/js?v=2.exp&key=J32BZ-X4WYW-XBNRG-OY7LI-DBKTH-JSFMT"></script>
    <script>
        geocoder = new qq.maps.Geocoder({
            complete: function (result) {
                $('#lat').val(result.detail.location.lat);
                $('#lng').val(result.detail.location.lng);
            },
            error: function (r) {
                alert('获取失败，请输入正确地址重试')
            }
        });

        function getLocation() {
            var address = $("#adrress").val();
            geocoder.getLocation(address);
        }
    </script>

</body>

</html>